<!DOCTYPE html>
<html lang="zh-Hans">
<meta name="theme-color" content="#FFFFFF">


<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
  <meta name="theme-color" content="#202020"/>
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
  <link rel="icon" sizes="any" mask href="/images/favicon.ico" /> 
  
  

  <!-- viewjs support -->
  
    <!-- for theme: default is false -->
    <!-- for page: default is true -->
    <link  href="./css/viewer.min.css" rel="stylesheet" >
    <script src="./js/viewer.min.js" type="text/javascript" charset="utf-8"></script>
  
  
  
    <meta name="keywords" content="tools," />
  

  
    <meta name="description" content="分享 Java 技术，做有趣的程序员" />
  
  
  <link rel="icon" type="image/x-icon" href="/logo.png">
  <title>Aria2 GUI最佳实践 [ H E R O ]</title>
  
    <!-- stylesheets list from config.yml -->
    
      <link rel="stylesheet" href="//cdn.bootcss.com/pure/1.0.0/pure-min.css">
    
      <link rel="stylesheet" href="/css/xoxo.css">
    
  
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
  <div class="nav-container">
    <nav id="menu" class="home-menu pure-menu pure-menu-horizontal">
  <a class="pure-menu-heading" href="/">
    <!-- <img class="avatar" src="/images/logo.png"> -->
    <span class="title">H E R O</span>
  </a>

  <ul class="pure-menu-list clearfix">
      
          
            <li class="pure-menu-item"><a href="/" class="pure-menu-link">首页</a></li>
          
      
          
            <li class="pure-menu-item"><a href="/archives/" class="pure-menu-link">归档</a></li>
          
      
          
            <li class="pure-menu-item"><a href="/tags/" class="pure-menu-link">标签</a></li>
          
      
          
            <li class="pure-menu-item"><a href="/about/" class="pure-menu-link">关于</a></li>
          
      
          
            <li class="pure-menu-item"><a href="/atom.xml" class="pure-menu-link">订阅</a></li>
          
      
  </ul>
   
</nav>
  </div>

  <div class="container" id="content-outer">
    <div class="inner" id="content-inner">
      <div class="post-container">
  <article class="post" id="post">
    <header class="post-header text-center">
      <h1 class="title">
        Aria2 GUI最佳实践
      </h1>
      <span>
        
        <time class="time" datetime="2019-04-09T11:06:03.000Z">
          2019-04-09
        </time>
        
      </span>
      <span class="slash">/</span>
      <span class="post-meta">
        <span class="post-tags">
          <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/tools/" rel="tag">tools</a></li></ul>
        </span>
      </span>
      
     
    </header>

    <div class="post-content">
      <p>目前用的爽的下载工具，通过搭配  Chrome 和 自己写的一些脚本达到不输迅雷的用户体验。</p>
<blockquote>
<p>本文在 MacOS 下可以通过所有步骤，其他平台需要自行修改相关步骤</p>
</blockquote>
<span id="more"></span>
<h2 id="Aria2-下载"><a href="#Aria2-下载" class="headerlink" title="Aria2 下载"></a>Aria2 下载</h2><p>推荐使用 <a target="_blank" rel="noopener" href="https://brew.sh/index_zh-cn">Homebrew</a> 安装</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">brew install aria2</span><br></pre></td></tr></table></figure>
<h2 id="配置-Aria2"><a href="#配置-Aria2" class="headerlink" title="配置 Aria2"></a>配置 Aria2</h2><p>将下面的内容复制到 <code>/Users/用户名/.aria2/aria2.conf</code> 里面，用户名是你 Mac 的用户名。<br>同时建立session文件<br><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">touch ~/.aria2/aria2.session</span><br></pre></td></tr></table></figure></p>
<p>文中注释了一些选项含义，所以的含义需要看这个网址获取 <a target="_blank" rel="noopener" href="https://aria2.github.io/manual/en/html/aria2c.html?highlight=download#cmdoption-on-bt-download-complete">aria2c(1) — aria2 1.34.0 documentation</a></p>
<p>不建议修改下面的除了 用户文件夹之外的内容，这些内容都是经过实践得出的比较优秀的配置，下载速度较快</p>
<p>需要修改下面的用户名 jacob 改为你自己的用户名方可使用。</p>
<figure class="highlight properties"><table><tr><td class="code"><pre><span class="line"><span class="comment">## &#x27;#&#x27;开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##</span></span><br><span class="line"><span class="comment">## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释  ##</span></span><br><span class="line"><span class="comment">## 添加了@和默认启用的选项都是系统需要调用的，请不要随意改动否则可能无法正常运行</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">## 日志</span></span><br><span class="line"><span class="comment">#log-level=info</span></span><br><span class="line"><span class="comment">#log=/Users/jacob/.aria2/aria2.log</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 文件保存相关 ##</span></span><br><span class="line"><span class="comment"># 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置</span></span><br><span class="line"><span class="comment"># 此项 OS X 无法使用 $HOME 及 ~/ 设置路径  建议使用 /users/用户名/downloads</span></span><br><span class="line"><span class="attr">dir</span>=<span class="string">/Users/jacob/Downloads</span></span><br><span class="line"><span class="comment"># 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M</span></span><br><span class="line"><span class="meta">disk-cache</span>=<span class="string">0M</span></span><br><span class="line"><span class="comment"># 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc</span></span><br><span class="line"><span class="comment"># 预分配所需时间: none &lt; falloc ? trunc &lt; prealloc</span></span><br><span class="line"><span class="comment"># falloc和trunc则需要文件系统和内核支持</span></span><br><span class="line"><span class="comment"># NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项</span></span><br><span class="line"><span class="comment"># file-allocation=none</span></span><br><span class="line"><span class="comment"># 断点续传</span></span><br><span class="line"><span class="attr">continue</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 最大重试次数, 设置为0表示不限制重试次数, 默认:5</span></span><br><span class="line"><span class="meta">max-tries</span>=<span class="string">5</span></span><br><span class="line"><span class="comment"># 设置重试等待的秒数, 默认:0</span></span><br><span class="line"><span class="meta">retry-wait</span>=<span class="string">5</span></span><br><span class="line"><span class="comment">## 下载连接相关 ##</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 最大同时下载任务数, 运行时可修改, 默认:5</span></span><br><span class="line"><span class="meta">max-concurrent-downloads</span>=<span class="string">20</span></span><br><span class="line"><span class="comment"># 同一服务器连接数, 添加时可指定, 默认:1</span></span><br><span class="line"><span class="meta">max-connection-per-server</span>=<span class="string">16</span></span><br><span class="line"><span class="comment"># 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M</span></span><br><span class="line"><span class="comment"># 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载</span></span><br><span class="line"><span class="meta">min-split-size</span>=<span class="string">1024K</span></span><br><span class="line"><span class="comment"># 单个任务最大线程数, 添加时可指定, 默认:5</span></span><br><span class="line"><span class="attr">split</span>=<span class="string">16</span></span><br><span class="line"><span class="comment"># 整体下载速度限制, 运行时可修改, 默认:0</span></span><br><span class="line"><span class="meta">max-overall-download-limit</span>=<span class="string">0</span></span><br><span class="line"><span class="comment"># 单个任务下载速度限制, 默认:0</span></span><br><span class="line"><span class="meta">max-download-limit</span>=<span class="string">0</span></span><br><span class="line"><span class="comment"># 整体上传速度限制, 运行时可修改, 默认:0</span></span><br><span class="line"><span class="meta">max-overall-upload-limit</span>=<span class="string">0</span></span><br><span class="line"><span class="comment"># 单个任务上传速度限制, 默认:0</span></span><br><span class="line"><span class="meta">max-upload-limit</span>=<span class="string">0</span></span><br><span class="line"><span class="comment"># 禁用IPv6, 默认:false</span></span><br><span class="line"><span class="meta">disable-ipv6</span>=<span class="string">false</span></span><br><span class="line"><span class="comment">#运行覆盖已存在文件</span></span><br><span class="line"><span class="meta">allow-overwrite</span>=<span class="string">true</span></span><br><span class="line"><span class="comment">#自动重命名</span></span><br><span class="line"><span class="meta">auto-file-renaming</span>=<span class="string">true</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 进度保存相关 ##</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 从会话文件中读取下载任务</span></span><br><span class="line"><span class="meta">input-file</span>=<span class="string">/Users/jacob/.aria2/aria2.session</span></span><br><span class="line"><span class="comment"># 在Aria2退出时保存`错误/未完成`的下载任务到会话文件</span></span><br><span class="line"><span class="meta">save-session</span>=<span class="string">/Users/jacob/.aria2/aria2.session</span></span><br><span class="line"><span class="comment"># 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0</span></span><br><span class="line"><span class="meta">save-session-interval</span>=<span class="string">30</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## RPC相关设置 ##</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 启用RPC, 默认:false</span></span><br><span class="line"><span class="meta">enable-rpc</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 允许所有来源, 默认:false</span></span><br><span class="line"><span class="meta">rpc-allow-origin-all</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 允许非外部访问, 默认:false</span></span><br><span class="line"><span class="meta">rpc-listen-all</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同</span></span><br><span class="line"><span class="comment">#event-poll=select</span></span><br><span class="line"><span class="comment"># RPC监听端口, 端口被占用时可以修改, 默认:6800</span></span><br><span class="line"><span class="comment"># 使用本客户端请勿修改此项</span></span><br><span class="line"><span class="meta">rpc-listen-port</span>=<span class="string">6800</span></span><br><span class="line"><span class="comment"># 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项</span></span><br><span class="line"><span class="meta">rpc-secret</span>=<span class="string">maria.rpc.2018</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## BT/PT下载相关 ##</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true</span></span><br><span class="line"><span class="comment">#follow-torrent=true</span></span><br><span class="line"><span class="comment"># BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999</span></span><br><span class="line"><span class="meta">listen-port</span>=<span class="string">51413</span></span><br><span class="line"><span class="comment"># 单个种子最大连接数, 默认:55</span></span><br><span class="line"><span class="comment">#bt-max-peers=55</span></span><br><span class="line"><span class="comment"># 打开DHT功能, PT需要禁用, 默认:true</span></span><br><span class="line"><span class="meta">enable-dht</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 打开IPv6 DHT功能, PT需要禁用</span></span><br><span class="line"><span class="comment">#enable-dht6=false</span></span><br><span class="line"><span class="comment"># DHT网络监听端口, 默认:6881-6999</span></span><br><span class="line"><span class="comment">#dht-listen-port=6881-6999</span></span><br><span class="line"><span class="comment"># 本地节点查找, PT需要禁用, 默认:false</span></span><br><span class="line"><span class="meta">bt-enable-lpd</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 种子交换, PT需要禁用, 默认:true</span></span><br><span class="line"><span class="meta">enable-peer-exchange</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 每个种子限速, 对少种的PT很有用, 默认:50K</span></span><br><span class="line"><span class="comment">#bt-request-peer-speed-limit=50K</span></span><br><span class="line"><span class="comment"># 客户端伪装, PT需要</span></span><br><span class="line"><span class="meta">peer-id-prefix</span>=<span class="string">-TR2770-</span></span><br><span class="line"><span class="meta">user-agent</span>=<span class="string">Transmission/2.77</span></span><br><span class="line"><span class="comment"># 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0</span></span><br><span class="line"><span class="meta">seed-ratio</span>=<span class="string">0</span></span><br><span class="line"><span class="comment"># 强制保存会话, 即使任务已经完成, 默认:false</span></span><br><span class="line"><span class="comment"># 较新的版本开启后会在任务完成后依然保留.aria2文件</span></span><br><span class="line"><span class="comment">#force-save=false</span></span><br><span class="line"><span class="comment"># BT校验相关, 默认:true</span></span><br><span class="line"><span class="comment">#bt-hash-check-seed=true</span></span><br><span class="line"><span class="comment"># 继续之前的BT任务时, 无需再次校验, 默认:false</span></span><br><span class="line"><span class="meta">bt-seed-unverified</span>=<span class="string">true</span></span><br><span class="line"><span class="comment"># 保存磁力链接元数据为种子文件(.torrent文件), 默认:false</span></span><br><span class="line"><span class="meta">bt-save-metadata</span>=<span class="string">true</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># bt-tracker数据来自https://github.com/ngosang/trackerslist/blob/master/trackers_all_udp.txt</span></span><br><span class="line"></span><br><span class="line"><span class="meta">bt-tracker</span>=<span class="string">udp://tracker.coppersurfer.tk:6969/announce,udp://tracker.open-internet.nl:6969/announce,udp://tracker.leechers-paradise.org:6969/announce,udp://tracker.internetwarriors.net:1337/announce,udp://9.rarbg.to:2710/announce,udp://9.rarbg.me:2710/announce,udp://tracker.opentrackr.org:1337/announce,http://tracker3.itzmx.com:6961/announce,http://tracker1.itzmx.com:8080/announce,udp://exodus.desync.com:6969/announce,udp://explodie.org:6969/announce,udp://ipv4.tracker.harry.lu:80/announce,udp://denis.stalker.upeer.me:6969/announce,udp://tracker.torrent.eu.org:451/announce,udp://tracker.tiny-vps.com:6969/announce,udp://open.demonii.si:1337/announce,http://vps02.net.orel.ru:80/announce,http://re-tracker.uz:80/announce,http://open.acgnxtracker.com:80/announce,udp://tracker4.itzmx.com:2710/announce,</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 一些脚本</span></span><br><span class="line"><span class="comment">#下载完成后字段执行操作</span></span><br><span class="line"><span class="meta">on-bt-download-complete</span>=<span class="string">/Users/jacob/.aria2/aria2_on_bt_download_complete.sh</span></span><br><span class="line"><span class="meta">on-download-complete</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_complete.sh</span></span><br><span class="line"><span class="meta">on-download-error</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_error.sh</span></span><br><span class="line"><span class="meta">on-download-pause</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_pause.sh</span></span><br><span class="line"><span class="meta">on-download-start</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_start.sh</span></span><br><span class="line"><span class="meta">on-download-stop</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_stop.sh</span></span><br></pre></td></tr></table></figure>
<h2 id="调试-Aria2"><a href="#调试-Aria2" class="headerlink" title="调试 Aria2"></a>调试 Aria2</h2><p>Aria2 启动可能会有问题，我们需要调试成功之后才然后设置开机启动，否则无法查看错误信息，</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">/usr/local/bin/aria2c --conf-path=/Users/jacob/.aria2/aria2.conf</span><br></pre></td></tr></table></figure>
<p>通过上面的命令可以看到提示，如果没有错误就可以进入下一步了。如果有错误根据错误提示解决问题</p>
<h2 id="配置-Aria2-开机启动"><a href="#配置-Aria2-开机启动" class="headerlink" title="配置 Aria2 开机启动"></a>配置 Aria2 开机启动</h2><p>aira2 每次都要自己启动，十分麻烦，但是 aria2 资源占用很低，适合在后台常驻，所以可以设置为开机启动。</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">cd ~/Library/LaunchAgents</span><br><span class="line">touch com.aria2c.plist</span><br></pre></td></tr></table></figure>
<p>将下面的内容放入 <code>com.aria2c.plist</code></p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></span><br><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">plist</span> <span class="meta-keyword">PUBLIC</span> <span class="meta-string">&quot;-//Apple//DTD PLIST 1.0//EN&quot;</span> <span class="meta-string">&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">plist</span> <span class="attr">version</span>=<span class="string">&quot;1.0&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dict</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">key</span>&gt;</span>KeepAlive<span class="tag">&lt;/<span class="name">key</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">true</span>/&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">key</span>&gt;</span>Label<span class="tag">&lt;/<span class="name">key</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">string</span>&gt;</span>com.aria2c<span class="tag">&lt;/<span class="name">string</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">key</span>&gt;</span>ProgramArguments<span class="tag">&lt;/<span class="name">key</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">array</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">string</span>&gt;</span>/usr/local/bin/aria2c<span class="tag">&lt;/<span class="name">string</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">string</span>&gt;</span>--conf-path=/Users/jacob/.aria2/aria2.conf<span class="tag">&lt;/<span class="name">string</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">array</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">key</span>&gt;</span>RunAtLoad<span class="tag">&lt;/<span class="name">key</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">true</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dict</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plist</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>加载配置</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">launchctl load ~/Library/LaunchAgents/com.aria2c.plist</span><br></pre></td></tr></table></figure>
<p>此时 通过 <code>ps aux | grep &quot;aria2&quot;</code>可以看到 aria2 已经启动，如果没有启动可以注销Mac用户后登陆即可看到 aria2 在运行中。以后 aira2 就可以开机启动了。</p>
<h2 id="GUI-推荐"><a href="#GUI-推荐" class="headerlink" title="GUI 推荐"></a>GUI 推荐</h2><p>Aria2 有很多 GUI，这个推荐一个 Chrome 插件用作 GUI， Chrome 的功能我们可以让他看起来像一个独立的应用。</p>
<p>安装 <a target="_blank" rel="noopener" href="https://chrome.google.com/webstore/detail/aria2-for-chrome/mpkodccbngfoacfalldjimigbofkhgjn">Aria2 for Chrome - Chrome 网上应用店</a></p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wmsowtn4j30he0i076a.jpg" alt="image-20190409195941716"></p>
<p>右键插件图标进入选项，设置 rpc 网址为 <code>http://token:maria.rpc.2018@localhost:6800/jsonrpc</code></p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wmu6com6j30yt0u0n1f.jpg" alt="image-20190409200110273"></p>
<p>然后单击插件图标即可看到提示 Aria2 已连接的提示</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wmvewqh5j30y40rota2.jpg" alt="image-20190409200222405"></p>
<p>如果这里无法连接，需要在 GUI 内部设置token等信息</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1xep6hxkvj31tm0mujw0.jpg" alt="image-20190410120509073"></p>
<p>下面我们可以让这个插件变成一个应用，如果你不感兴趣可以直接看下一节。</p>
<p>右键点击 插件 图标，点击 打开AriaNG 文字，进入页面</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wmyn8cffj30hs0fywfp.jpg" alt="image-20190409200528048"></p>
<p>然后将这个页面导出为应用</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wmzyuwz3j311x0u0tha.jpg" alt="image-20190409200644372"></p>
<p>此时在mac的应用里就会有一个 AriaNG 应用了，图标可以自行定制，如何修改图标自己搜索下吧</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wn0qhed3j30i80f0tag.jpg" alt="image-20190409200728757"></p>
<p>效果如下</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1xenq065vj31880u0k3r.jpg" alt="image-20190410120344344"></p>
<h2 id="使用-Aria2-下载磁力链接"><a href="#使用-Aria2-下载磁力链接" class="headerlink" title="使用 Aria2 下载磁力链接"></a>使用 Aria2 下载磁力链接</h2><p>普通下载不必多讲，按照插件和 GUI 的页面可以很容易的进行下载，这里说说如何下载 磁力链接。Aria2 磁力链接的速度会很慢，甚至可能无法下载，此时我们可以通过修改 配置中的 bt-tracker 选项来获得高速下载，速度不输迅雷。</p>
<p>可以通过复制 <a target="_blank" rel="noopener" href="https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt">https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt</a>  的内容然后修改一下格式，配置给 Aria2，因为 trackers 一直在变化我也写了一个python3 的脚本来辅助更新。内容如下</p>
<figure class="highlight python"><table><tr><td class="code"><pre><span class="line"><span class="keyword">import</span> urllib.request</span><br><span class="line"><span class="keyword">import</span> urllib.parse</span><br><span class="line"></span><br><span class="line">path = <span class="string">&#x27;/Users/jacob/.aria2/aria2.conf&#x27;</span></span><br><span class="line"></span><br><span class="line">url = <span class="string">&#x27;https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt&#x27;</span></span><br><span class="line">f = urllib.request.urlopen(url)</span><br><span class="line">s = f.read().decode(<span class="string">&#x27;utf-8&#x27;</span>)</span><br><span class="line">bt_tracker = s.replace(<span class="string">&#x27;\n\n&#x27;</span>, <span class="string">&#x27;,&#x27;</span>)</span><br><span class="line"></span><br><span class="line">data = <span class="string">&#x27;&#x27;</span></span><br><span class="line"><span class="keyword">with</span> <span class="built_in">open</span>(path, <span class="string">&#x27;r+&#x27;</span>) <span class="keyword">as</span> f:</span><br><span class="line">    <span class="keyword">for</span> line <span class="keyword">in</span> f.readlines():</span><br><span class="line">        <span class="keyword">if</span> line.find(<span class="string">&#x27;bt-tracker&#x27;</span>) == <span class="number">0</span>:</span><br><span class="line">            line = <span class="string">&#x27;bt-tracker=%s&#x27;</span> % bt_tracker + <span class="string">&#x27;\n&#x27;</span></span><br><span class="line"></span><br><span class="line">        data += line</span><br><span class="line"></span><br><span class="line"><span class="keyword">with</span> <span class="built_in">open</span>(path, <span class="string">&#x27;r+&#x27;</span>) <span class="keyword">as</span> f:</span><br><span class="line">    f.writelines(data)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>通过运行上面的脚本可以一键更新 bt-tracker 内容，注意配置修改之后必须要重启 Aria2 才可以生效。可以通过 kill 进程来实现，我们的开机启动配置会自动重启一个 Aria 进程。</p>
<h2 id="配置使用下载完成后通知"><a href="#配置使用下载完成后通知" class="headerlink" title="配置使用下载完成后通知"></a>配置使用下载完成后通知</h2><p>先看看效果：</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1xemfqc4dj30jk03uq3w.jpg" alt="image-20190410120230775"></p>
<p>上面的插件是没有实现下载完成后通知的，这样其实有些尴尬，每次都要去看看写没写完，可以通过 Aria2 自带的 钩子函数来实现。对应在 conf 里的配置是这些</p>
<figure class="highlight properties"><table><tr><td class="code"><pre><span class="line"><span class="comment">## 一些脚本</span></span><br><span class="line"><span class="comment">#下载完成后字段执行操作</span></span><br><span class="line"><span class="meta">on-bt-download-complete</span>=<span class="string">/Users/jacob/.aria2/aria2_on_bt_download_complete.sh</span></span><br><span class="line"><span class="meta">on-download-complete</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_complete.sh</span></span><br><span class="line"><span class="meta">on-download-error</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_error.sh</span></span><br><span class="line"><span class="meta">on-download-pause</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_pause.sh</span></span><br><span class="line"><span class="meta">on-download-start</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_start.sh</span></span><br><span class="line"><span class="meta">on-download-stop</span>=<span class="string">/Users/jacob/.aria2/aria2_on_download_stop.sh</span></span><br></pre></td></tr></table></figure>
<p>这些脚本的内容如下</p>
<p>/Users/jacob/.aria2/aria2_on_bt_download_complete.sh</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">/usr/local/bin/terminal-notifier -title &quot;Aria2&quot; -subtitle &quot;BT下载完成&quot; -message &quot;&quot; -activate com.google.Chrome.app.Default-hpjnfnejkleckpmhmjppopcbnedoocmg  -appIcon /Users/jacob/Applications/Chrome\ Apps.localized/Default\ hpjnfnejkleckpmhmjppopcbnedoocmg.app/Contents/Resources/app.icns</span><br></pre></td></tr></table></figure>
<p>/Users/jacob/.aria2/aria2_on_download_complete.sh</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">/usr/local/bin/terminal-notifier -title &quot;Aria2&quot; -subtitle &quot;下载完成&quot; -message $msg -execute &quot;/usr/bin/open $3&quot; -appIcon /Users/jacob/Applications/Chrome\ Apps.localized/Default\ hpjnfnejkleckpmhmjppopcbnedoocmg.app/Contents/Resources/app.icns</span><br></pre></td></tr></table></figure>
<p>/Users/jacob/.aria2/aria2_on_download_error.sh</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">var=$3</span><br><span class="line">msg=$&#123;var##*/&#125;</span><br><span class="line">/usr/local/bin/terminal-notifier -title &quot;Aria2&quot; -subtitle &quot;下载失败&quot; -message $msg -activate com.google.Chrome.app.Default-hpjnfnejkleckpmhmjppopcbnedoocmg  -appIcon /Users/jacob/Applications/Chrome\ Apps.localized/Default\ hpjnfnejkleckpmhmjppopcbnedoocmg.app/Contents/Resources/app.icns</span><br></pre></td></tr></table></figure>
<p>/Users/jacob/.aria2/aria2_on_download_pause.sh</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">var=$3</span><br><span class="line">msg=$&#123;var##*/&#125;</span><br><span class="line">/usr/local/bin/terminal-notifier -title &quot;Aria2&quot; -subtitle &quot;暂停下载&quot; -message $msg -activate com.google.Chrome.app.Default-hpjnfnejkleckpmhmjppopcbnedoocmg  -appIcon /Users/jacob/Applications/Chrome\ Apps.localized/Default\ hpjnfnejkleckpmhmjppopcbnedoocmg.app/Contents/Resources/app.icns</span><br></pre></td></tr></table></figure>
<p>/Users/jacob/.aria2/aria2_on_download_start.sh</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">var</span>=$<span class="number">3</span></span><br><span class="line">msg=$&#123;var##*/&#125;</span><br><span class="line">/usr/local/bin/terminal-notifier -title <span class="string">&quot;Aria2&quot;</span> -subtitle <span class="string">&quot;开始下载&quot;</span> -message $msg -activate com.google.Chrome.app.Default-hpjnfnejkleckpmhmjppopcbnedoocmg  -appIcon /Users/jacob/Applications/Chrome\ Apps.localized/Default\ hpjnfnejkleckpmhmjppopcbnedoocmg.app/Contents/Resources/app.icns</span><br></pre></td></tr></table></figure>
<p>使用这些脚本需要安装软件 <a target="_blank" rel="noopener" href="https://github.com/julienXX/terminal-notifier">julienXX/terminal-notifier: Send User Notifications on macOS from the command-line.</a></p>
<p>安装方式 <code>brew install terminal-notifier</code></p>
<p>appIcon 就是通知时候的图标，可以自定义。这样就实现了下载完成后通知，并且点击通知就能够打开下载的文件。terminal-notifier 一定要使用全路径名，否则无法生效。</p>
<h2 id="Aria2-满速下载百度云文件"><a href="#Aria2-满速下载百度云文件" class="headerlink" title="Aria2 满速下载百度云文件"></a>Aria2 满速下载百度云文件</h2><p>安装 Chrome 插件<a target="_blank" rel="noopener" href="https://github.com/acgotaku/BaiduExporter">acgotaku/BaiduExporter: Assistant for Baidu to export download links to aria2/aria2-rpc</a></p>
<p>安装方式看 GitHub 的 readme， 然后配置本地 Aria2</p>
<p>设置在这里：</p>
<p><img src="https://image-hosting-1251780645.cos.ap-beijing.myqcloud.com/fromSina/006tNc79ly1g1wo1bmaqpj310s0cmq53.jpg" alt="image-20190409204236064"></p>
<p>配置 URL 为 <code>http://token:maria.rpc.2018@localhost:6800/jsonrpc</code></p>
<p>以后使用 导出下载即可获得满速下载。</p>

    </div>
    <br>
    <div>全文完。</div>
  </article>
  <div class="toc-container">
    
  <div id="toc" class="toc-article">
    <strong class="toc-title">目录</strong>
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Aria2-%E4%B8%8B%E8%BD%BD"><span class="toc-text">Aria2 下载</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-Aria2"><span class="toc-text">配置 Aria2</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B0%83%E8%AF%95-Aria2"><span class="toc-text">调试 Aria2</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-Aria2-%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8"><span class="toc-text">配置 Aria2 开机启动</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#GUI-%E6%8E%A8%E8%8D%90"><span class="toc-text">GUI 推荐</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8-Aria2-%E4%B8%8B%E8%BD%BD%E7%A3%81%E5%8A%9B%E9%93%BE%E6%8E%A5"><span class="toc-text">使用 Aria2 下载磁力链接</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E4%BD%BF%E7%94%A8%E4%B8%8B%E8%BD%BD%E5%AE%8C%E6%88%90%E5%90%8E%E9%80%9A%E7%9F%A5"><span class="toc-text">配置使用下载完成后通知</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Aria2-%E6%BB%A1%E9%80%9F%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E4%BA%91%E6%96%87%E4%BB%B6"><span class="toc-text">Aria2 满速下载百度云文件</span></a></li></ol>
  </div>


  </div>
</div>
<div class="copyright">
    <span>本作品采用</span>
    <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by/4.0/">知识共享署名 4.0 国际许可协议</a>
    <span>进行许可。 转载时请注明原文链接。</span>
</div>
<div class="share" style="width: 100%;">
  <img src="/images/wechat-qcode.jpg" height="200" width="200" alt="" style="margin: auto; display: block;" />

  <div style="margin: auto; text-align: center; font-size: 0.8em; color: grey;">关注“豆菽技术”公众号</div>
  
</div>

  
    <div class="post-nav">
      <div class="post-nav-item post-nav-next">
        
          <span>〈 </span>
          <a href="/preparation-and-init-of-classloader.html" rel="next" title="Java类加载器的准备和初始化">
          Java类加载器的准备和初始化
          </a>
        
      </div>
  
      <div class="post-nav-item post-nav-prev">
          
          <a href="/record-of-deadlock-analytics.html" rel="prev" title="线上死锁分析解决纪实">
            线上死锁分析解决纪实
          </a>
          <span>〉</span>
        
      </div>
    </div>
  

  <section class="disqus-comments">
    <div id="disqus_thread">
      <noscript>Please enable JavaScript to view the <a target="_blank" rel="noopener" href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    </div>
  </section>

  <script>
    var disqus_shortname = 'coderbean';
    
    var disqus_url = 'https://jacobchang.cn/best-practices-of-aria2.html';
    
    (function(){
      var dsq = document.createElement('script');
      dsq.type = 'text/javascript';
      dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
  </script>

  <script id="dsq-count-scr" src="//coderbean.disqus.com/count.js" async></script>



    </div>

    

  </div>
  <footer class="footer text-center">
    <div id="bottom-inner">
        <a class="bottom-item-hide" href="https://jacobchang.cn/" target="_blank">主站</a>
        <!-- <a class="bottom-item-hide">·</a> -->
        <!-- <a class="bottom-item-hide" href="" target="_blank">备份站点</a> -->
        <a class="bottom-item-hide">·</a>
        <a class="bottom-item-hide" href="https://github.com/coderbean" target="_blank">GitHub</a>
        <a class="bottom-item-hide">·</a>
        <a class="bottom-item" href="https://hexo.io" target="_blank">Powered by hexo</a>
        <a class="bottom-item">·</a>
        <a class="bottom-item" href="https://github.com/coderbean/hexo-theme-xoxo" target="_blank">Theme xoxo</a>
    </div>
    <div id="bottom-inner">
        <a class="bottom-item-hide" target="_blank" rel="noopener" href="https://beian.miit.gov.cn">备案号：浙ICP备2021033778号-1</a> 
        <a class="bottom-item-hide">·</a>
        <a id="copyright" class="bottom-item"></a>
    </div>
</footer>

<script language="javascript" type="text/javascript">
    var df = new Date();
    var year = df.getFullYear();
    document.getElementById("copyright").innerHTML = "Copyright © 2017 – " + year + " 黄小豆";
</script>
  

<script>
  (function(window, document, undefined) {

    var timer = null;

    function returnTop() {
      cancelAnimationFrame(timer);
      timer = requestAnimationFrame(function fn() {
        var oTop = document.body.scrollTop || document.documentElement.scrollTop;
        if (oTop > 0) {
          document.body.scrollTop = document.documentElement.scrollTop = oTop - 50;
          timer = requestAnimationFrame(fn);
        } else {
          cancelAnimationFrame(timer);
        }
      });
    }

    var hearts = [];
    window.requestAnimationFrame = (function() {
      return window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        function(callback) {
          setTimeout(callback, 1000 / 60);
        }
    })();
    init();

    function init() {
      css(".heart{z-index:9999;width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
      attachEvent();
      gameloop();
      addMenuEvent();
    }

    function gameloop() {
      for (var i = 0; i < hearts.length; i++) {
        if (hearts[i].alpha <= 0) {
          document.body.removeChild(hearts[i].el);
          hearts.splice(i, 1);
          continue;
        }
        hearts[i].y--;
        hearts[i].scale += 0.004;
        hearts[i].alpha -= 0.013;
        hearts[i].el.style.cssText = "left:" + hearts[i].x + "px;top:" + hearts[i].y + "px;opacity:" + hearts[i].alpha + ";transform:scale(" + hearts[i].scale + "," + hearts[i].scale + ") rotate(45deg);background:" + hearts[i].color;
      }
      requestAnimationFrame(gameloop);
    }

    /**
     * 设置点击事件
     * 
     * - 回到顶部
     * - 出现爱心
     */
    function attachEvent() {
      var old = typeof window.onclick === "function" && window.onclick;
      var logo = document.getElementById("menu");
      if (logo) {
        logo.onclick = function(event) {
          // returnTop();
          old && old();
          createHeart(event);
        }
      }
      
    }

    function createHeart(event) {
      var d = document.createElement("div");
      d.className = "heart";
      hearts.push({
        el: d,
        x: event.clientX - 5,
        y: event.clientY - 5,
        scale: 1,
        alpha: 1,
        color: randomColor()
      });
      document.body.appendChild(d);
    }

    function css(css) {
      var style = document.createElement("style");
      style.type = "text/css";
      try {
        style.appendChild(document.createTextNode(css));
      } catch (ex) {
        style.styleSheet.cssText = css;
      }
      document.getElementsByTagName('head')[0].appendChild(style);
    }

    function randomColor() {
      // return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + ")";
      return "#F44336";
    }

    function addMenuEvent() {
      var menu = document.getElementById('menu-main-post');
      if (menu) {
        var toc = document.getElementById('toc');
        if (toc) {
          menu.onclick = function() {
            if (toc) {
              if (toc.style.display == 'block') {
                toc.style.display = 'none';
              } else {
                toc.style.display = 'block';
              }
            }
          };
        } else {
          menu.style.display = 'none';
        }
      }
    }

  })(window, document);
</script>

  


  <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
              m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-155080039-1', 'auto');
      ga('send', 'pageview');
  </script>


  
<link rel='stylesheet' href='https://s3-us-west-2.amazonaws.com/s.cdpn.io/1462889/unicons.css'>

<div class="progress-wrap">
    <svg class="progress-circle svg-content" width="100%" height="100%" viewBox="-1 -1 102 102">
        <path d="M50,1 a49,49 0 0,1 0,98 a49,49 0 0,1 0,-98" />
    </svg>
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js'></script>
<script>

    (function ($) {
        "use strict";
        $(document).ready(function () {
            "use strict";

            //Scroll back to top

            var progressPath = document.querySelector('.progress-wrap path');
            var pathLength = progressPath.getTotalLength();
            progressPath.style.transition = progressPath.style.WebkitTransition = 'none';
            progressPath.style.strokeDasharray = pathLength + ' ' + pathLength;
            progressPath.style.strokeDashoffset = pathLength;
            progressPath.getBoundingClientRect();
            progressPath.style.transition = progressPath.style.WebkitTransition = 'stroke-dashoffset 10ms linear';
            var updateProgress = function () {
                var scroll = $(window).scrollTop();
                var height = $(document).height() - $(window).height();
                var progress = pathLength - (scroll * pathLength / height);
                progressPath.style.strokeDashoffset = progress;
            }
            updateProgress();
            $(window).scroll(updateProgress);
            var offset = 50;
            var duration = 550;
            jQuery(window).on('scroll', function () {
                if (jQuery(this).scrollTop() > offset) {
                    jQuery('.progress-wrap').addClass('active-progress');
                } else {
                    jQuery('.progress-wrap').removeClass('active-progress');
                }
            });
            jQuery('.progress-wrap').on('click', function (event) {
                event.preventDefault();
                jQuery('html, body').animate({ scrollTop: 0 }, duration);
                return false;
            })


        });

    })(jQuery);
</script>

  
<!-- for theme: default is false -->
<!-- for page: default is true -->
<!-- 图片查看器实例配置 -->
<script type="text/javascript">
    //默认设置， 可以根据个人需求和喜好进行配置
    //详细参考官方说明
    Viewer.setDefaults({
        //设置初始缩放 default: 1
        zoomRatio: [0.5],
        // 过渡动画
        transition:true,
        // 显示工具条
        toolbar: false,
    });
    //获得content中所有的图片， 不同主题可能有所不同
    //为了和其他的图片区别开来 所以在markdown中插入图片的时候使用独特的记号
    //为了一次性得到所有的图片我这里采用的是class = 'article-image'
    var article = document.querySelector('.post-content');
    if(article!=null) {
        var imageList = article.getElementsByTagName('img');
        //将获取到的HTMLCollections转化成Array
        var imageArray = new Array();
        Array.prototype.forEach.call(imageList, element => {
            imageArray.push(element);
        });
        //设置每个图片成为图片组
        Array.prototype.forEach.call(imageList, element => {
            var viewer1 = new Viewer(element);
            viewer1.images = imageArray;
            viewer1.length = imageArray.length;
        });
    }

    
</script>

  
  <! -- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
                processEscapes: true
                    
}
  
        });
</script>

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
                  
}
    
        });
</script>

<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
            var all = MathJax.Hub.getAllJax(), i;
            for(i=0; i < all.length; i += 1) {
                            all[i].SourceElement().parentNode.className += ' has-jax';
                                    
            }
                
        });
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>

</script>

  
</body>

</html>